#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#include <unistd.h>
#include <pthread.h>

void printid(char* arg) {
	printf("%s: %d - %x\n", arg, getpid(), pthread_self());
}

void* thr_fn1(void* arg) {
	printid("thread 1");
	return ((void*)1);
}

void* thr_fn2(void* arg) {
	printid("thread 2");
	return ((void*)2);
}

int main() {
	int err;
	pthread_t tid1, tid2;
	void* tret;

	printid("main");

	pthread_create(&tid1, NULL, thr_fn1, NULL);
	pthread_create(&tid2, NULL, thr_fn2, NULL);

	pthread_join(tid1, &tret);
	printf("thr_fn1: %d\n", (int)tret);

	pthread_join(tid2, &tret);
	printf("thr_fn2: %d\n", (int)tret);

	return 0;
}